#!/usr/local/bin/python3

import threading
import time
import sys
import signal

RUNNING = True

class a(threading.Thread):
    global RUNNING

    def run(self):
        while RUNNING:   
            print('a', end='')
            sys.stdout.flush()
            time.sleep(0.2)
        
class b(threading.Thread):
    global RUNNING

    def run(self):
        while RUNNING:
            print('b', end='')
            sys.stdout.flush()
            time.sleep(0.2)


def signal_handler(signal, frame):
    global RUNNING

    print('\nYou pressed Ctrl+C!', end = '\n')
    RUNNING = False
                    
signal.signal(signal.SIGINT, signal_handler)

a().start()
b().start()
